package com.zlzlib.liblayoutmanager;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * @Desc:
 * @Copyright:
 * @DateTime: 2021/8/10 15:03
 * @Author zlz
 * @Version 1.0
 */
final class SavedScrollState implements Parcelable {

    int position;
    float offset;
    boolean isReverseLayout;

    public SavedScrollState() {
    }

    protected SavedScrollState(Parcel in) {
        this.position = in.readInt();
        this.offset = in.readFloat();
        this.isReverseLayout = in.readInt() == 1;
    }

    public SavedScrollState(SavedScrollState other) {
        this.position = other.position;
        this.offset = other.offset;
        this.isReverseLayout = other.isReverseLayout;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.position);
        dest.writeFloat(this.offset);
        dest.writeInt(this.isReverseLayout ? 1 : 0);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<SavedScrollState> CREATOR = new Creator<SavedScrollState>() {
        @Override
        public SavedScrollState createFromParcel(Parcel in) {
            return new SavedScrollState(in);
        }

        @Override
        public SavedScrollState[] newArray(int size) {
            return new SavedScrollState[size];
        }
    };

}
